package com.hust.bridgecheck.controller.Settings;

import com.hust.bridgecheck.entity.Notify;
import com.hust.bridgecheck.entity.Threshold;
import com.hust.bridgecheck.entity.WarningSetting;
import com.hust.bridgecheck.service.Settings.NotifyService;
import com.hust.bridgecheck.service.Settings.ThresholdService;
import com.hust.bridgecheck.service.Settings.WarningSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("setting")
public class SettingController {
    @Autowired
    private ThresholdService thresholdService;

    @Autowired
    private NotifyService notifyService;

    @Autowired
    private WarningSService warningSService;

    @PostMapping("/deleteThresholdByID")
    private void deleteThresholdByID(@RequestParam("TID") Integer ThresholdID){
        thresholdService.deleteThreshold(ThresholdID);
    }

    @PostMapping("/deleteNotifyByID")
    private void deleteNotifyByID(@RequestParam("NID") Integer NotifyID){
        notifyService.deleteNotify(NotifyID);
    }

    @PostMapping("/getThresholdBySensorID")
    private Threshold getThresholdBySensorID(@RequestParam("SID") String SensorID){
        return thresholdService.getThresoldBySenosorID(SensorID);
    }

    @GetMapping("/getAllWarningSetting")
    private List<WarningSetting> getAllWarningSetting(){
        return warningSService.getAllWarningSetting();
    }

    @PostMapping("/getNotify")
    private Notify getNotifyByID(@RequestParam("NID") Integer NotifyID){
        return notifyService.getNotify(NotifyID);
    }

}
